package com.ijunfu.interceptors;

import com.fasterxml.jackson.databind.cfg.HandlerInstantiator;
import com.ijunfu.utils.HeadThreadLocal;
import org.aopalliance.intercept.Interceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/12/16 13:16
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@Component
public class AuthInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        HeadThreadLocal headThreadLocal = HeadThreadLocal.getThreadLocalInstance();

        headThreadLocal.setToken(request.getHeader("token"));

        return super.preHandle(request, response, handler);
    }
}
